

class Demo {
    
	// Assumes that the array a has at least 1 element
	// Complexity: O(logN)
	// Note that the mid point must be included in one
	//   of the recursive calls to be considered

    static int FindLargest(int[] a, int low, int high) {
        int mid = (low + high)/2;
	  if (mid == low || mid == high)
		if (a[low - 1] >= a[high - 1])
			return a[low - 1];
		else
			return a[high - 1];
        int x = FindLargest(a, mid, high);
        int y = FindLargest(a, low, mid - 1);
	  if (x >= y)
            return x;
	  else 
	   	return y;
    }

    public static void main (String[] args) {
	int a[] = {3, 5, 73, 2, 17, 1, 12, 45, 6, 39, 4};
	System.out.println(FindLargest(a, 1, 11));
    }
}

